package org.terramagnet.mvcframework.http.signature;

import org.terramagnet.mvcframework.http.Connection;
import java.util.Collection;

/**
 * 签名算法.
 *
 * @author lip
 */
public interface Signer {

    /**
     * Apply this sign algorithm.
     *
     * @param parameters request parameters. These parameters already sorted by nature order.
     * @return sign result string
     * @throws SignException an exception occured when apply this sign algorithm.
     */
    public String sign(Collection<Connection.KeyVal> parameters) throws SignException;

    /**
     * A name of sign result ,that will be added to request parameters.
     *
     * @return sign result parameter name. Defautl is "{@code sign}".
     */
    public String name();

    /**
     * Set the secret key for this signer.
     *
     * @param secret secret key
     * @return this signer for chain
     */
    public Signer secret(String secret);
}
